package action.custom;

import java.util.List;

import core.action.BaseAction;
import exception.Exceptions;
import model.credit.Lcbank;
import model.personal.Personalbasic;
import service.custom.CustomLcBankInforService;
import service.custom.PersonalService;
import util.Sessions;

public class PersonalAction extends BaseAction{
	private PersonalService personalService;
	
	private Personalbasic pbasic;
	private Integer id;
	private String PFLAG;
	
	
	private List<String> basicbank;
	private List<String> basicdepositbank;
	
	private CustomLcBankInforService customLcBankInforService;
	
	private List<Lcbank> lcbankList;
	
	
	public String getPFLAG() {
		return PFLAG;
	}


	public void setPFLAG(String pFLAG) {
		PFLAG = pFLAG;
	}


	public Integer getId() {
		return id;
	}


	public void setId(Integer id) {
		this.id = id;
	}


	public String savePersonalBasic() throws Exceptions{
		System.out.println(pbasic.getId());
		System.out.println(pbasic.getName());
		personalService.savePersonalBasic(pbasic);
		customLcBankInforService.delete(pbasic.getId(), 1, 1);
		this.customLcBankInforService.save(pbasic.getId(), 1, basicbank, basicdepositbank, 1);
		System.out.println("save pBasic success!!");
		
		Sessions.set("companyid", pbasic.getId());
		MessageJump("保存成功","personalAction!personalread?PFLAG=BASIC");
		
		return "message";

	}
	
	public String personalDelete(){
		pbasic= personalService.personalShow(id);
		personalService.personalDelete(pbasic);
		MessageJump("删除成功","customList!personallist");
		return "message";
		
	}
	
	
	public String personalShow() throws Exceptions{
		
		if(id != null){
			Sessions.set("companyid",id);
			pbasic= personalService.personalShow(id);
			this.lcbankList = this.customLcBankInforService.findList((Integer)Sessions.get("companyid"), 1, 1);
		}else if(Sessions.get("companyid") != null){
			pbasic= personalService.personalShow((Integer)Sessions.get("companyid"));
			this.lcbankList = this.customLcBankInforService.findList((Integer)Sessions.get("companyid"), 1, 1);
		}
		Sessions.set("eflage", "show");
		super.successResultValue="NewPersonalBasic";
		return "success";
	}
	
	
	public String personalread() throws Exceptions{
		
		if(id != null){
			Sessions.set("companyid",id);
			pbasic= personalService.personalShow(id);
			this.lcbankList = this.customLcBankInforService.findList((Integer)Sessions.get("companyid"), 1, 1);
		}else if(Sessions.get("companyid") != null){
			pbasic= personalService.personalShow((Integer)Sessions.get("companyid"));
			this.lcbankList = this.customLcBankInforService.findList((Integer)Sessions.get("companyid"), 1, 1);
		}
		//Sessions.set("eflage", "show");
		super.successResultValue="NewPersonalBasic";
		return "success";
	}
	
	
	
	public String personalModify() throws Exceptions{
		if(id != null){
			Sessions.set("companyid",id);
			pbasic= personalService.personalShow(id);
			this.lcbankList = this.customLcBankInforService.findList((Integer)Sessions.get("companyid"), 1, 1);
		}else if(Sessions.get("companyid") != null){
			pbasic= personalService.personalShow((Integer)Sessions.get("companyid"));
			this.lcbankList = this.customLcBankInforService.findList((Integer)Sessions.get("companyid"), 1, 1);
		}
		Sessions.set("eflage", "Modify");
		super.successResultValue="NewPersonalBasic";
		return "success";
	}

	public PersonalService getPersonalService() {
		return personalService;
	}

	public void setPersonalService(PersonalService personalService) {
		this.personalService = personalService;
	}

	public Personalbasic getPbasic() {
		return pbasic;
	}

	public void setPbasic(Personalbasic pbasic) {
		this.pbasic = pbasic;
	}


	public List<String> getBasicbank() {
		return basicbank;
	}


	public void setBasicbank(List<String> basicbank) {
		this.basicbank = basicbank;
	}


	public List<String> getBasicdepositbank() {
		return basicdepositbank;
	}


	public void setBasicdepositbank(List<String> basicdepositbank) {
		this.basicdepositbank = basicdepositbank;
	}


	public CustomLcBankInforService getCustomLcBankInforService() {
		return customLcBankInforService;
	}


	public void setCustomLcBankInforService(
			CustomLcBankInforService customLcBankInforService) {
		this.customLcBankInforService = customLcBankInforService;
	}


	public List<Lcbank> getLcbankList() {
		return lcbankList;
	}


	public void setLcbankList(List<Lcbank> lcbankList) {
		this.lcbankList = lcbankList;
	}
}
